package com.ixiaowo.springcouldconsumermovie;

import com.ixiaowo.springcouldconsumermovie.entity.User;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

/**
 * feign  调用方式 demo
 */
@FeignClient("microservice-provider-user")
public interface UserFeignClient {
    /**
     * 编写接口 添加调用方式  注意:两个坑 1.不支持@GetMapping()注解方式
 *                                        2.@PathVariable得设置value默认值
     * @param id
     * @return
     */
    @RequestMapping(value = "/simple/{id}",method = RequestMethod.GET)
    public User findById(@PathVariable("id") Long id);

    /**
     * feign  post方式请求
     * @param user
     * @return
     */
    @RequestMapping(value = "/user",method = RequestMethod.POST)
    User postUser(@RequestBody User user);
}
